import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
	collapsed: false,
	topNavState: 'home',
	leftNavState: 'home',
	openTab: [], //所有打开的路由
	activeIndex: '/index',
}
const getters = {}
const actions = {}
const mutations = {
	// 添加tabs
	add_tabs(state, data) {
		this.state.openTab.push(data)
	},
	// 删除tabs
	delete_tabs(state, route) {
		let index = 0
		for (let option of state.openTab) {
			if (option.route === route) {
				break
			}
			index++
		}
		this.state.openTab.splice(index, 1)
	},
	// 设置当前激活的tab
	set_active_index(state, index) {
		this.state.activeIndex = index
	},
}
import login_reqstore from './modules/login_reqstore'

export default new Vuex.Store({
	state,
	getters,
	mutations,
	actions,
	modules: {
		login_reqstore,
	},
})
